<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name', 100)->comment('用户姓名');
            $table->string('nickname', 100)->comment('用户昵称');
            $table->string('email', 100)->nullable()->comment('用户邮件地址');
            $table->string('openid', 40)->nullable()->comment('微信 openid');
            $table->string('access_token')->nullable()->comment('微信 access_token');
            $table->tinyInteger('sex')->default(\App\Models\User::SEX_NV)->comment('性别');
            $table->string('province', 20)->nullable()->comment('省份');
            $table->string('city', 20)->nullable()->comment('所在城市');
            $table->string('country', 20)->default('中国')->comment('所在国家');
            $table->string('language', 20)->default('zh_CN')->comment('语言');
            $table->string('avatar',255)->nullable()->comment('微信用户图片');
            $table->string('provider', 20)->nullable()->comment('服务提供商');
            $table->string('unionid', 20)->unique()->nullable()->comment('唯一性校验, 用于多端比如:微信公众和小程序的用户唯一性校验');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
